<template>
	<div class="system-warn-container" :style="[{ 'overflow-x': 'hidden' }, { height: screenHeight + 'px' }]">
		<el-form :inline="false" size="mini" label-position="left">
			<el-row :gutter="15">
				<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb10">
					<el-card shadow="hover" header="未绑定电子标签">
						<el-form-item label="1、是否开启">
							<el-switch v-model="noBindTagDtoWarning.status" />
						</el-form-item>
						<el-form-item label="2、物品登记后">
							<div style="float: left"><el-input-number v-model="noBindTagDtoWarning.minute" /></div>
							<div style="float: left; margin-left: 10px">分钟后提醒</div>
						</el-form-item>
						<!-- <el-form-item label="3、推送人">
							<el-select filterable v-model="noBindTagDtoWarning.popUserCodes" :multiple="true" placeholder="请选择推送人">
								<el-option v-for="item in options.tsrs" :key="item.value" :label="item.label" :value="item.value"> </el-option>
							</el-select>
						</el-form-item> -->
						<el-form-item label="3、推送内容设置">
							<el-input :rows="2" v-model="noBindTagDtoWarning.popContent" style="width: 300px"></el-input>
						</el-form-item>
						<el-button type="primary" style="margin-top: 10px" size="mini" @click="onSubmit()">保存</el-button>
					</el-card>
				</el-col>
				<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb15">
					<el-card shadow="hover" header="未及时入库">
						<el-form-item label="1、是否开启">
							<el-switch v-model="overtimeStockWarning.status" />
						</el-form-item>
						<el-form-item label="2、物品登记后">
							<div style="float: left"><el-input-number v-model="overtimeStockWarning.minute"></el-input-number></div>
							<div style="float: left; margin-left: 10px">分钟后提醒</div>
						</el-form-item>
						<!-- <el-form-item label="3、推送人">
							<el-select filterable v-model="overtimeStockWarning.popUserCodes" :multiple="true" placeholder="请选择推送人">
								<el-option v-for="item in options.tsrs" :key="item.value" :label="item.label" :value="item.value"> </el-option>
							</el-select>
						</el-form-item> -->
						<el-form-item label="3、推送内容设置">
							<el-input :rows="2" v-model="overtimeStockWarning.popContent" style="width: 300px"></el-input>
						</el-form-item>
						<el-button type="primary" style="margin-top: 10px" size="mini" @click="onSubmit()">保存</el-button>
					</el-card>
				</el-col>
			</el-row>
			<el-row :gutter="15">
				<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb15">
					<el-card shadow="hover" header="未及时回库">
						<el-form-item label="1、是否开启">
							<el-switch v-model="overtimeRevertWarning.status" />
						</el-form-item>
						<el-form-item label="2、回库时间">
							<el-row>
								<el-checkbox v-model="overtimeRevertWarning.residueChecked" label=" "></el-checkbox>剩余
								<el-input-number
									v-model="overtimeRevertWarning.residueMinute"
									style="width: 100px; margin-left: 10px; margin-right: 10px"
								></el-input-number
								>分钟后提醒
							</el-row>
							<el-row style="margin-top: 8px">
								<el-checkbox v-model="overtimeRevertWarning.beOverdueChecked" label=" "></el-checkbox>逾期
								<el-input-number
									v-model="overtimeRevertWarning.beOverdueMinute"
									style="width: 100px; margin-left: 10px; margin-right: 10px"
								></el-input-number
								>分钟后提醒</el-row
							>
						</el-form-item>
						<!-- <el-form-item label="3、推送人">
							<el-select filterable v-model="overtimeRevertWarning.popUserCodes" :multiple="true" placeholder="请选择推送人">
								<el-option v-for="item in options.tsrs" :key="item.value" :label="item.label" :value="item.value"> </el-option>
							</el-select>
						</el-form-item> -->
						<el-form-item label="3、推送内容设置">
							<el-input :rows="2" v-model="overtimeRevertWarning.popContent" style="width: 300px"></el-input>
						</el-form-item>
						<el-button type="primary" style="margin-top: 10px" size="mini" @click="onSubmit()">保存</el-button>
					</el-card>
				</el-col>

				<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb15">
					<el-card shadow="hover" header="库存容量预警">
						<el-form-item label="1、是否开启">
							<el-switch v-model="stockQuantityWarning.status" />
						</el-form-item>
						<el-form-item label="2、">
							<el-row>
								<el-checkbox v-model="stockQuantityWarning.greaterOrEqualVolumeChecked" label=" "></el-checkbox>大于等于最大容量，<el-input-number
									v-model="stockQuantityWarning.greaterOrEqualVolume"
									style="width: 100px; margin-left: 10px; margin-right: 10px"
								></el-input-number>
								每<el-input-number
									style="width: 100px; margin-left: 10px; margin-right: 10px"
									v-model="stockQuantityWarning.greaterOrEqualVolumeMinute"
								></el-input-number>
								分钟提醒一次
							</el-row>
							<el-row style="margin-top: 8px">
								<el-checkbox v-model="stockQuantityWarning.lessVolumeChecked" label=" "></el-checkbox>小于最大容量
								<el-input-number
									v-model="stockQuantityWarning.lessVolume"
									style="width: 100px; margin-left: 10px; margin-right: 10px"
								></el-input-number
								>内， 每<el-input-number
									style="width: 100px; margin-left: 10px; margin-right: 10px"
									v-model="stockQuantityWarning.lessVolumeMinute"
								></el-input-number>
								分钟提醒一次
							</el-row>
						</el-form-item>
						<!-- <el-form-item label="3、推送人">
							<el-select filterable v-model="stockQuantityWarning.popUserCodes" :multiple="true" placeholder="请选择推送人">
								<el-option v-for="item in options.tsrs" :key="item.value" :label="item.label" :value="item.value"> </el-option>
							</el-select>
						</el-form-item> -->
						<el-form-item label="3、推送内容设置">
							<el-input :rows="2" v-model="stockQuantityWarning.popContent" style="width: 300px"></el-input>
						</el-form-item>
						<el-button type="primary" style="margin-top: 10px" size="mini" @click="onSubmit()">保存</el-button>
					</el-card>
				</el-col>
			</el-row>
			<el-row :gutter="15">
				<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb15">
					<el-card shadow="hover" header="保存超期提醒">
						<el-form-item label="1、是否开启">
							<el-switch v-model="overtimeSaveWarning.status" />
						</el-form-item>
						<el-form-item label="2、超期时间">
							<el-row>
								<el-checkbox v-model="overtimeSaveWarning.residueChecked" label=" "></el-checkbox>剩余
								<el-input-number
									v-model="overtimeSaveWarning.residueMinute"
									style="width: 100px; margin-left: 10px; margin-right: 10px"
								></el-input-number>
								分钟过后提醒
							</el-row>
							<el-row style="margin-top: 8px">
								<el-checkbox v-model="overtimeSaveWarning.beOverdueChecked" label=" "></el-checkbox>逾期
								<el-input-number
									v-model="overtimeSaveWarning.beOverdueMinute"
									style="width: 100px; margin-left: 10px; margin-right: 10px"
								></el-input-number>
								分钟过后提醒
							</el-row>
						</el-form-item>
						<!-- <el-form-item label="3、推送人">
							<el-select filterable v-model="overtimeSaveWarning.popUserCodes" :multiple="true" placeholder="请选择推送人">
								<el-option v-for="item in options.tsrs" :key="item.value" :label="item.label" :value="item.value"> </el-option>
							</el-select>
						</el-form-item> -->
						<el-form-item label="3、处置意见">
							<el-row>
								，入库
								<el-input-number
									v-model="overtimeSaveWarning.residueHour"
									style="width: 100px; margin-left: 10px; margin-right: 10px"
								></el-input-number>
								小时过后提醒
							</el-row>
						</el-form-item>
						<el-form-item label="4、保存超期推送内容设置">
							<el-input :rows="2" v-model="overtimeSaveWarning.popContent" style="width: 300px"></el-input>
						</el-form-item>
						<el-form-item label="5、处置意见超期推送内容设置">
							<el-input :rows="2" v-model="overtimeSaveWarning.npopContent" style="width: 300px"></el-input>
						</el-form-item>
						<el-button type="primary" style="margin-top: 10px" size="mini" @click="onSubmit()">保存</el-button>
					</el-card>
				</el-col>
				<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb15">
					<el-card shadow="hover" header="异常出库报警">
						<el-form-item label="1、是否开启">
							<el-switch v-model="unusualLevelWarning.status" />
						</el-form-item>
						<!-- <el-form-item label="2、推送人">
							<el-select filterable v-model="unusualLevelWarning.popUserCodes" :multiple="true" placeholder="请选择推送人">
								<el-option v-for="item in options.tsrs" :key="item.value" :label="item.label" :value="item.value"> </el-option>
							</el-select>
						</el-form-item> -->
						<el-form-item label="2、推送内容设置">
							<el-input :rows="2" v-model="unusualLevelWarning.popContent" style="width: 300px"></el-input>
						</el-form-item>
						<el-button type="primary" style="margin-top: 10px" size="mini" @click="onSubmit()">保存</el-button>
					</el-card>
				</el-col>
			</el-row>
			<el-row :gutter="15">
				<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb15">
					<el-card shadow="hover" header="环境预警">
						<el-form-item label="1、是否开启">
							<el-switch v-model="environmentalWarning.status" />
						</el-form-item>
						<el-form-item label="2、">
							<el-row>
								<el-checkbox v-model="environmentalWarning.temperaturChecked" label=" "></el-checkbox>超出温度范围
								<el-input-number
									v-model="environmentalWarning.lowTemperature"
									style="width: 100px; margin-left: 10px; margin-right: 10px"
								></el-input-number>
								℃ --
								<el-input-number
									v-model="environmentalWarning.tallTemperature"
									style="width: 100px; margin-left: 10px; margin-right: 10px"
								></el-input-number
								>℃， 每<el-input-number
									style="width: 100px; margin-left: 10px; margin-right: 10px"
									v-model="environmentalWarning.temperatureMinute"
								></el-input-number>
								分钟提醒一次
							</el-row>
							<el-row style="margin-top: 8px">
								<el-checkbox v-model="environmentalWarning.humidityChecked" label=" "></el-checkbox>超出湿度范围
								<el-input-number
									v-model="environmentalWarning.lowHumidity"
									style="width: 100px; margin-left: 10px; margin-right: 10px"
								></el-input-number>
								--
								<el-input-number
									v-model="environmentalWarning.tallHumidity"
									style="width: 100px; margin-left: 10px; margin-right: 10px"
								></el-input-number
								>， 每<el-input-number
									style="width: 100px; margin-left: 10px; margin-right: 10px"
									v-model="environmentalWarning.humidityMinute"
								></el-input-number>
								分钟提醒一次
							</el-row>
							<el-row style="margin-top: 8px">
								<el-checkbox v-model="environmentalWarning.smogChecked" label=" "></el-checkbox>烟感报警，每
								<el-input-number
									v-model="environmentalWarning.smogMinute"
									style="width: 100px; margin-left: 10px; margin-right: 10px"
								></el-input-number>
								分钟提醒一次
							</el-row>
							<el-row style="margin-top: 8px">
								<el-checkbox v-model="environmentalWarning.waterChecked" label=" "></el-checkbox>水侵报警，每
								<el-input-number
									v-model="environmentalWarning.waterMinute"
									style="width: 100px; margin-left: 10px; margin-right: 10px"
								></el-input-number>
								分钟提醒一次
							</el-row>
							<el-row style="margin-top: 8px">
								<el-checkbox v-model="environmentalWarning.airChecked" label=" "></el-checkbox>超出空气质量范围
								<el-input-number v-model="environmentalWarning.lowAir" style="width: 100px; margin-left: 10px; margin-right: 10px"></el-input-number>
								--
								<el-input-number v-model="environmentalWarning.tallAir" style="width: 100px; margin-left: 10px; margin-right: 10px"></el-input-number
								>， 每<el-input-number
									style="width: 100px; margin-left: 10px; margin-right: 10px"
									v-model="environmentalWarning.airMinute"
								></el-input-number>
								分钟提醒一次
							</el-row>
						</el-form-item>
						<!-- <el-form-item label="3、推送人">
							<el-select filterable v-model="environmentalWarning.popUserCodes" :multiple="true" placeholder="请选择推送人">
								<el-option v-for="item in options.tsrs" :key="item.value" :label="item.label" :value="item.value"> </el-option>
							</el-select>
						</el-form-item> -->
						<el-form-item label="3、温度推送内容设置">
							<el-input :rows="2" v-model="environmentalWarning.temperatureContent" style="width: 300px"></el-input>
						</el-form-item>
						<el-form-item label="4、湿度推送内容设置">
							<el-input :rows="2" v-model="environmentalWarning.humidityContent" style="width: 300px"></el-input>
						</el-form-item>
						<el-form-item label="5、烟感推送内容设置">
							<el-input :rows="2" v-model="environmentalWarning.smogContent" style="width: 300px"></el-input>
						</el-form-item>
						<el-form-item label="6、水侵推送内容设置">
							<el-input :rows="2" v-model="environmentalWarning.waterContent" style="width: 300px"></el-input>
						</el-form-item>
						<el-form-item label="7、空气质量推送内容设置">
							<el-input :rows="2" v-model="environmentalWarning.airContent" style="width: 300px"></el-input>
						</el-form-item>
						<el-button type="primary" style="margin-top: 10px" size="mini" @click="onSubmit()">保存</el-button>
					</el-card>
				</el-col>
				<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb15"> </el-col>
			</el-row>
		</el-form>
	</div>
</template>

<script lang="ts">
import { ref, toRefs, reactive, onMounted } from 'vue';
import { ElMessage } from 'element-plus';
import { initDic } from '/@/common';
import { saveWarn, geteWarn } from '/@/api/common/index';
export default {
	name: 'systemWarn',
	components: {},
	setup() {
		const state = reactive({
			options: { tsrs: [] },
			noBindTagDtoWarning: {
				status: false,
				popUserCodes: [],
				popContent: '',
				minute: 60,
			},
			overtimeStockWarning: {
				status: false,
				popUserCodes: [],
				popContent: '',
				minute: 60,
			},
			overtimeRevertWarning: {
				status: false,
				popUserCodes: [],
				popContent: '',
				residueMinute: 60,
				residueChecked: false,
				beOverdueMinute: 60,
				beOverdueChecked: false,
			},
			unusualLevelWarning: {
				status: false,
				popUserCodes: [],
				popContent: '',
			},
			overtimeSaveWarning: {
				status: false,
				popUserCodes: [],
				popContent: '',
				npopContent: '',
				residueMinute: 60,
				residueHour: 24,
				residueChecked: false,
				beOverdueMinute: 60,
				beOverdueChecked: false,
			},
			stockQuantityWarning: {
				status: false,
				popUserCodes: [],
				popContent: '',
				greaterOrEqualVolumeMinute: 60,
				greaterOrEqualVolumeChecked: false,
				greaterOrEqualVolume: 0,
				lessVolume: 0,
				lessVolumeMinute: 60,
				lessVolumeChecked: false,
			},
			environmentalWarning: {
				status: false,
				popUserCodes: [],
				popContent: '',
				lowTemperature: 0,
				tallTemperature: 0,
				temperatureMinute: 60,
				temperatureContent: '',
				temperaturChecked: false,
				lowHumidity: 0,
				tallHumidity: 0,
				humidityMinute: 60,
				humidityContent: '',
				humidityChecked: false,
				smogMinute: 60,
				smogContent: '',
				smogChecked: false,
				waterMinute: 60,
				waterContent: '',
				waterChecked: false,
				lowAir: 0,
				tallAir: 0,
				airMinute: 60,
				airContent: '',
				airChecked: false,
			},
			screenHeight: document.body.clientHeight - 120,
		});
		const checked1 = ref(true);
		initDic(state.options);
		onMounted(() => {});
		function onSubmit() {
			saveWarn({
				noBindTagDtoWarning: state.noBindTagDtoWarning,
				overtimeStockWarning: state.overtimeStockWarning,
				overtimeRevertWarning: state.overtimeRevertWarning,
				unusualLevelWarning: state.unusualLevelWarning,
				overtimeSaveWarning: state.overtimeSaveWarning,
				stockQuantityWarning: state.stockQuantityWarning,
				environmentalWarning: state.environmentalWarning,
			}).then((res: any) => {
				if (res.success) {
					getWarn();
					ElMessage({
						message: '保存成功',
						type: 'success',
					});
				} else {
					ElMessage.error(res.msg);
				}
			});
		}
		function getWarn() {
			geteWarn('Warn', 'Warn').then((res: any) => {
				if (res.success) {
					state.noBindTagDtoWarning = res.data.noBindTagDtoWarning;
					state.overtimeStockWarning = res.data.overtimeStockWarning;
					state.overtimeRevertWarning = res.data.overtimeRevertWarning;
					state.unusualLevelWarning = res.data.unusualLevelWarning;
					state.overtimeSaveWarning = res.data.overtimeSaveWarning;
					state.stockQuantityWarning = res.data.stockQuantityWarning;
					state.environmentalWarning = res.data.environmentalWarning;
				} else {
					ElMessage({
						message: res.msg,
						type: 'warning',
					});
				}
			});
		}
		getWarn();
		return {
			checked1,
			state,
			onSubmit,
			...toRefs(state),
		};
	},
};
</script>
